﻿using BLL.Interface;
using Common.Extensions;
using Microsoft.AspNetCore.Mvc;
using Model.DTO.Article;
using Model.DTO.Public.GetList;
using Model.DTO.Public.OperateId;

namespace TianXiaHuiForumManagementSystem.Controllers.Admin
{
    [Route("Admin/[controller]")]
    [ApiController]
    public class ArticleController : ControllerBase
    {
        private readonly IArticleBLL _articleBLL;
        public ArticleController(IArticleBLL articleBLL)
        {
            _articleBLL = articleBLL;
        }
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("AddArticle")]
        public async Task<string> AddArticle(AddArticleDTO param)
        {
            var result = await _articleBLL.AddArticle(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("DeleteArticle")]
        public async Task<string> DeleteArticle(OperateIdDTO_LONG param)
        {
            var result = await _articleBLL.DeleteArticle(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 编辑文章
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("EditArticle")]
        public async Task<string> EditArticle(EditArticleDTO param)
        {
            var result = await _articleBLL.EditArticle(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 获取文章列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("GetArticleList")]
        public async Task<string> GetArticleList(GetListDTO param)
        {
            var result = await _articleBLL.GetArticleList(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 绑定文章类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost, Route("BindArticleTypes")]
        public async Task<string> BindArticleTypes(OperateIdDTO_LONG_INT param)
        {
            var result = await _articleBLL.BindArticleTypes(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 获取文章绑定的文章类型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet, Route("GetArticleBindArticleType")]
        public async Task<string> GetArticleBindArticleType(int id)
        {
            var result = await _articleBLL.GetArticleBindArticleType(id);
            return result.ToJsonFormat();
        }
    }
}
